package com.ruoyi.baoming.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baoming.domain.TbCandidate;
import com.ruoyi.baoming.service.ITbCandidateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 考生信息Controller
 * 
 * @author xiaosong
 * @date 2025-03-10
 */
@Api(tags = "专升本-考生信息管理")
@RestController
@RequestMapping("/baoming/TBcandidate")
public class TbCandidateController extends BaseController
{
    @Autowired
    private ITbCandidateService tbCandidateService;

    /**
     * 查询考生信息列表
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:list')")
    @GetMapping("/list")
    @ApiOperation("专升本考生信息管理 - 分页查询列表")
    public TableDataInfo list(TbCandidate tbCandidate)
    {
        startPage();
        List<TbCandidate> list = tbCandidateService.selectTbCandidateList(tbCandidate);
        return getDataTable(list);
    }

    /**
     * 导出考生信息列表
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:export')")
    @Log(title = "考生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("专升本考生信息管理 - 导出数据")
    public void export(HttpServletResponse response, TbCandidate tbCandidate)
    {
        List<TbCandidate> list = tbCandidateService.selectTbCandidateList(tbCandidate);
        ExcelUtil<TbCandidate> util = new ExcelUtil<TbCandidate>(TbCandidate.class);
        util.exportExcel(response, list, "考生信息数据");
    }

    /**
     * 获取考生信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("专升本考生信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbCandidateService.selectTbCandidateById(id));
    }

    /**
     * 新增考生信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:add')")
    @Log(title = "考生信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("专升本考生信息管理 - 新增数据")
    public AjaxResult add(@RequestBody TbCandidate tbCandidate)
    {
        return toAjax(tbCandidateService.insertTbCandidate(tbCandidate));
    }

    /**
     * 修改考生信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:edit')")
    @Log(title = "考生信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("专升本考生信息管理 - 修改数据")
    public AjaxResult edit(@RequestBody TbCandidate tbCandidate)
    {
        return toAjax(tbCandidateService.updateTbCandidate(tbCandidate));
    }

    /**
     * 删除考生信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:TBcandidate:remove')")
    @Log(title = "考生信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("专升本考生信息管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbCandidateService.deleteTbCandidateByIds(ids));
    }
}
